<template>
	<view class="goods">
		<view class="list ph-32 pt-32 mb-20" v-for="(item, index) in list" :key="index" @click="toDetail(item)">
			<!-- <view class="fs-28 fw-600 text-color4 ph-8">店铺一</view>  v-for="(item, index1) in 2" :key="index1"-->
			<view class="f ai-c jc-s-b pv-32">
				<image :src="item.picUrl[0]" class="w-140 h-140 b-12 mr-24" v-if="item.picUrl"></image>
				<view class="f ai-c js-c-b f1">
					<view class="f fd-c f1">
						<view class="fs-32 fw-600 text-color4 text-ellipsis-1">{{item.spuName}}</view>

						<view class="mt-8">
							<text class="fs-22 text-color8">¥</text>
							<text class="fs-36 fw-600 text-color8">{{item.price}}</text>
						</view>
					</view>
					<image src="http://cwht.ricecs.cn/app/index/star-select.png" class="w-32 h-32 ml-32"></image>
				</view>
			</view>
		</view>

	</view>
</template>
<script setup lang="ts">
	import { ref } from 'vue';
	import { favoriteLists } from '@/services/api/mine/index';
	import { favoriteDelete } from '@/services/api/shop/collect';
	const list = ref<any[]>([]);
	const listQuery = ref({
		pageNo: 1,
		pageSize: 10,
		collectionType: 2
	});
	getContentPage();
	async function getContentPage() {
		const { data } = await favoriteLists(listQuery.value);
		if (data.list.length > 0) {
			
			data.list.forEach((item : any, index : number) => {
				item.picUrl=JSON.parse(item.picUrl)
				list.value.push(item);
			});
		}
	}
	async function fav(item : any) {
		await favoriteDelete({ spuId: item.id });
		listQuery.value.pageNo = 1
		getContentPage();
	}
	function toDetail(item : any) {
		uni.navigateTo({
			url: `/pages_serve/productDetails/index?id=${item.id}`,
		});
	};
</script>
<style lang="scss" scoped>
	.goods {
		background: #f5f5f5;
		min-height: 100vh;

		.list {
			background: #fff;
		}
	}
</style>